package com.example.demo.controller;

import com.example.demo.domain.vo.ProcessInstanceVO;
import com.example.demo.domain.vo.TaskVO;
import com.example.demo.service.HuiQianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 会签类型
 * @Author: zsg
 * @Date: 2018/07/11 14:41
 */
@RestController
@RequestMapping("/huiqian")
public class HuiqianController {

    @Autowired
    private HuiQianService huiQianService;

    /**
     * 开启一个流程
     * @param processKey
     * @param userId
     * @param assigneeList 角色或者用户组  a,b,c,d这样的形式
     * @return
     */
    @GetMapping("startProcess")
    public List<ProcessInstanceVO>  startProcess(@RequestParam("processKey") String processKey, @RequestParam("userId") String userId,@RequestParam("assigneeList") String assigneeList){
        List<ProcessInstanceVO> processInstanceVOS = this.huiQianService.startProcess(processKey, userId, assigneeList);
        return processInstanceVOS;
    }

    /**
     * 完成任务
     * @param taskId
     */
    @GetMapping("completeTask")
    public void  completeTask(@RequestParam("taskId") String taskId){
        this.huiQianService.compeletTask(taskId);
    }

    /**
     * 获取某人的任务列表
     * @param userId
     * @return
     */
    @GetMapping("getTask")
    public List<TaskVO> getTask(@RequestParam("userId") String userId){
        List<TaskVO> mytask = this.huiQianService.getMytask(userId);
        return mytask;
    }
}
